// 用户相关请求模块

import request from '@/utils/request'

// 登录/注册
export const login = (data) => request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data
})

// 发送短信验证码
export const sendSms = mobile => request({
    method: 'GET',
    url: `/v1_0/sms/codes/${mobile}`,
})

// 获取用户信息
export const getCurrentUser = () => request({
    method: 'GET',
    url: '/v1_0/user',
})

// 获取用户频道列表
export const getUserChannels = () => request({
    method: 'GET',
    url: '/v1_0/user/channels',
})

// 关注用户
export const addFollow = (userId) => request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: { target: userId }
})

// 取消关注
export const deleteFollow = (userId) => request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${userId}`,
})


// 获取用户个人资料
export const getUserProfile = () => request({
    method: 'GET',
    url: '/v1_0/user/profile',
})

// 编辑用户个人资料
export const updateUserProfile = (data) => request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
})

// 编辑用户照片资料（头像、身份证照片）
export const updateUserPhoto = (data) => request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
})